<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<h:head>
	<h:outputScript library="javascript" name="jspdf.js"/>
	<h:outputScript library="javascript" name="jspdf.plugin.standard_fonts_metrics.js"/>
	<h:outputScript library="javascript" name="jspdf.plugin.split_text_to_size.js"/>              
	<h:outputScript library="javascript" name="jspdf.plugin.from_html.js"/>
	<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />		
	<h:outputStylesheet name="global.css" library="css" />
	<h:outputScript name="global.js" library="javascript"/>
	<h:outputScript name="validacao.js" library="javascript"/>
	<h:outputScript name="restricoes_de_campos.js" library="javascript"/>

		<script type="text/javascript">
		
			function htmlContent() {
				document.getElementById('list:htmlContent').value = document.querySelector('[id*="teste"]').innerHTML;
			}
			
			function teste() {
				window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('#teste').html()));
			}
			
		</script>
</h:head>

<h:body>
	<h1>Pdf export test</h1>
	
		<h:form id="list">
			<span id="teste">
				<p:panelGrid styleClass="panelGridCenter" id="tabelaTeste">
					<p:row>
						<p:column rowspan="2" styleClass="columnCenter">
							<p:outputLabel value="Tabela"/>
						</p:column>
						
						<p:column rowspan="2" styleClass="columnCenter" style="width:15%">
							<p:outputLabel value="Vigência"/>
						</p:column>
						
						<p:column colspan="5" styleClass="columnCenter">
							<p:outputLabel value="Taxas e comissões por prazo"/>
						</p:column>
					</p:row>
					
					<p:row>
						<p:column>
							<p:outputLabel value="Prazo (em meses)"/>
						</p:column>
		
						<p:column>
							<p:outputLabel value="Taxa de juros"/>
						</p:column>
		
						<p:column>
							<p:outputLabel value="Taxas para banco"/>
						</p:column>
		
						<p:column>
							<p:outputLabel value="Comissão"/>
						</p:column>
		
						<p:column>
							<p:outputLabel value="Complemento"/>
						</p:column>
					</p:row>
					
					<p:row>
						<p:column>
							<p:outputLabel value="0001 - Tabela A"/>
						</p:column>
						
						<p:column>
							<p:outputLabel value="A partir de 01/08/2014"/>
						</p:column>
						
						<p:column>
							<p:outputLabel value="1 a 6"/>
						</p:column>
						
						<p:column>
							<p:outputLabel value="10,50%"/>
						</p:column>
						
						<p:column>
							<p:outputLabel value="1,85%"/>
						</p:column>
						
						<p:column>
							<p:outputLabel value="15,00%"/>
						</p:column>
						
						<p:column>
							<p:outputLabel value="1,50%"/>
						</p:column>				
					</p:row>
									
				</p:panelGrid>
			</span>
			
			<br />
			
			<div align="center">
				<h:inputHidden id="htmlContent" value="#{pdfExport.htmlContent}"/>
				<p:commandButton onstart="htmlContent();" action="#{pdfExport.generatePDF2()}" value="Generate PDF"/>
				<p:commandButton id="btnExcel" value="Generate Excel" onstart="teste();"/>
			</div>
					
		</h:form>
	
</h:body>
</html>
